
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Loop Unrolling · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="mobile recommendation.html" />
    
    
    <link rel="prev" href="locality.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="./">
            
                <a href="./">
            
                    
                    前端进阶
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="Grid System.html">
            
                <a href="Grid System.html">
            
                    
                    Grid System
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="Handwritten signature.html">
            
                <a href="Handwritten signature.html">
            
                    
                    Handwritten Signature
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="Mobile Soft Keyboard.html">
            
                <a href="Mobile Soft Keyboard.html">
            
                    
                    Mobile Soft Keyboard
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="authentication.html">
            
                <a href="authentication.html">
            
                    
                    Authentication
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" >
            
                <span>
            
                    
                    Code
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" >
            
                <span>
            
                    
                    Four Operations
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="control loading.html">
            
                <a href="control loading.html">
            
                    
                    Control Loading
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="downfile.html">
            
                <a href="downfile.html">
            
                    
                    Downfile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="dynamic-routing.html">
            
                <a href="dynamic-routing.html">
            
                    
                    Dynamic Routing
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="ecs.html">
            
                <a href="ecs.html">
            
                    
                    Ecs
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="engineering.html">
            
                <a href="engineering.html">
            
                    
                    Engineering
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="eslint-vscode-format.html">
            
                <a href="eslint-vscode-format.html">
            
                    
                    Eslint Vscode Format
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="eventloop.html">
            
                <a href="eventloop.html">
            
                    
                    Eventloop
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="four-operations-1.html">
            
                <a href="four-operations-1.html">
            
                    
                    Four Operations 1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="four-operations-2.html">
            
                <a href="four-operations-2.html">
            
                    
                    Four Operations 2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="four-operations-3.html">
            
                <a href="four-operations-3.html">
            
                    
                    Four Operations 3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="four-operations-4.html">
            
                <a href="four-operations-4.html">
            
                    
                    Four Operations 4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="front end summary.html">
            
                <a href="front end summary.html">
            
                    
                    Front End Summary
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="git commit style.html">
            
                <a href="git commit style.html">
            
                    
                    Git Commit Style
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="git-commands.html">
            
                <a href="git-commands.html">
            
                    
                    Git Commands
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.22" data-path="high-quality-code.html">
            
                <a href="high-quality-code.html">
            
                    
                    High Quality Code
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.23" data-path="history.html">
            
                <a href="history.html">
            
                    
                    History
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.24" data-path="html-tag.html">
            
                <a href="html-tag.html">
            
                    
                    Html Tag
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.25" data-path="http-https-http2.html">
            
                <a href="http-https-http2.html">
            
                    
                    Http Https Http2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.26" data-path="ignore log.html">
            
                <a href="ignore log.html">
            
                    
                    Ignore Log
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.27" >
            
                <span>
            
                    
                    Imgs
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.28" data-path="javascript-optimization.html">
            
                <a href="javascript-optimization.html">
            
                    
                    Javascript Optimization
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.29" data-path="local application.html">
            
                <a href="local application.html">
            
                    
                    Local Application
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.30" data-path="locality.html">
            
                <a href="locality.html">
            
                    
                    Locality
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.31" data-path="loop-unrolling.html">
            
                <a href="loop-unrolling.html">
            
                    
                    Loop Unrolling
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.32" data-path="mobile recommendation.html">
            
                <a href="mobile recommendation.html">
            
                    
                    Mobile Recommendation
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.33" data-path="modal.html">
            
                <a href="modal.html">
            
                    
                    Modal
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.34" data-path="monitor.html">
            
                <a href="monitor.html">
            
                    
                    Monitor
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.35" data-path="performance.html">
            
                <a href="performance.html">
            
                    
                    Performance
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.36" data-path="print-talbe.html">
            
                <a href="print-talbe.html">
            
                    
                    Print Talbe
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.37" data-path="promise.html">
            
                <a href="promise.html">
            
                    
                    Promise
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.38" data-path="teaching.html">
            
                <a href="teaching.html">
            
                    
                    Teaching
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.39" data-path="vue refresh.html">
            
                <a href="vue refresh.html">
            
                    
                    Vue Refresh
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.40" data-path="vue-page-not-refresh.html">
            
                <a href="vue-page-not-refresh.html">
            
                    
                    Vue Page Not Refresh
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.41" data-path="why-learn-theory.html">
            
                <a href="why-learn-theory.html">
            
                    
                    Why Learn Theory
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Loop Unrolling</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x4F18;&#x5316;&#x5FAA;&#x73AF;&#x7684;&#x65B9;&#x6CD5;-&#x5FAA;&#x73AF;&#x5C55;&#x5F00;">&#x4F18;&#x5316;&#x5FAA;&#x73AF;&#x7684;&#x65B9;&#x6CD5;-&#x5FAA;&#x73AF;&#x5C55;&#x5F00;</h1>
<p>&#x5FAA;&#x73AF;&#x5C55;&#x5F00;&#x662F;&#x4E00;&#x79CD;&#x7A0B;&#x5E8F;&#x53D8;&#x6362;&#xFF0C;&#x901A;&#x8FC7;&#x589E;&#x52A0;&#x6BCF;&#x6B21;&#x8FED;&#x4EE3;&#x8BA1;&#x7B97;&#x7684;&#x5143;&#x7D20;&#x7684;&#x6570;&#x91CF;&#xFF0C;&#x51CF;&#x5C11;&#x5FAA;&#x73AF;&#x7684;&#x8FED;&#x4EE3;&#x6B21;&#x6570;&#x3002;</p>
<p>&#x7528;&#x4EE3;&#x7801;&#x6765;&#x8BF4;&#x660E;&#x5C31;&#x662F;&#x5C06;</p>
<pre><code>for (i = 0; i &lt; len; i++) {
    sum += arry[i]
}
</code></pre><p>&#x66FF;&#x6362;&#x4E3A;</p>
<pre><code>for (i = 0; i &lt; len; i += 2) {
    newSum += arry[i] + arry[i + 1]
}
</code></pre><p>&#x5FAA;&#x73AF;&#x5C55;&#x5F00;&#x5BF9;&#x4E8E;&#x7B97;&#x672F;&#x8FD0;&#x7B97;&#x6765;&#x8BF4;&#xFF0C;&#x4F18;&#x5316;&#x7684;&#x4F5C;&#x7528;&#x662F;&#x5F88;&#x5927;&#x7684;&#x3002;&#x6211;&#x5206;&#x522B;&#x5BF9;&#x6574;&#x6570;&#x8FD0;&#x7B97;&#x548C;&#x6D6E;&#x70B9;&#x6570;&#x8FD0;&#x7B97;&#x4F5C;&#x4E86;&#x591A;&#x6B21;&#x6D4B;&#x8BD5;&#xFF0C;&#x5F97;&#x51FA;&#x8868;&#x683C;&#x5982;&#x4E0B;&#xFF08;&#x65F6;&#x95F4;&#x4E3A;&#x6BEB;&#x79D2;&#xFF09;&#xFF1A;</p>
<table>
<thead>
<tr>
<th>&#x64CD;&#x4F5C;</th>
<th>&#x6574;&#x6570;</th>
<th>&#x6574;&#x6570;(&#x4F18;&#x5316;&#x540E;)</th>
<th>&#x6D6E;&#x70B9;&#x6570;</th>
<th>&#x6D6E;&#x70B9;&#x6570;(&#x4F18;&#x5316;&#x540E;)</th>
</tr>
</thead>
<tbody>
<tr>
<td>+</td>
<td>360</td>
<td>163</td>
<td>354</td>
<td>164</td>
</tr>
<tr>
<td>-</td>
<td>379</td>
<td>167</td>
<td>341</td>
<td>177</td>
</tr>
<tr>
<td>*</td>
<td>350</td>
<td>160</td>
<td>364</td>
<td>163</td>
</tr>
<tr>
<td>/</td>
<td>118</td>
<td>57</td>
<td>152</td>
<td>63</td>
</tr>
</tbody>
</table>
<h3 id="&#x6D4B;&#x8BD5;&#x73AF;&#x5883;">&#x6D4B;&#x8BD5;&#x73AF;&#x5883;</h3>
<ul>
<li>cpu:i5-7400</li>
<li>&#x6D4F;&#x89C8;&#x5668;: chrome 70.0.3538.110</li>
</ul>
<p>&#x8FD0;&#x7B97;&#x662F;&#x7528;&#x4E86;1&#x5343;&#x4E07;&#x4E2A;&#x6570;&#xFF0C;&#x53D6;&#x503C;&#x662F;&#x8FD0;&#x884C;&#x5341;&#x6B21;&#x6D4B;&#x8BD5;&#x5F97;&#x51FA;&#x7684;&#x5E73;&#x5747;&#x6570;&#x3002;&#x9644;&#x4E0A;&#x52A0;&#x6CD5;&#x6D4B;&#x8BD5;&#x7684;&#x4EE3;&#x7801;</p>
<pre><code>const arry = []
let num = 10000000
while (num) {
    arry.push(num)
    num--
}

let sum = 0
let i 
let len = arry.length
let last = new Date()
for (i = 0; i &lt; len; i++) {
    sum += arry[i]
}
let now = new Date()
console.log(now - last)

let newSum = 0
last = new Date()
for (i = 0; i &lt; len; i += 2) {
    newSum += arry[i] + arry[i + 1]
}
now = new Date()
console.log(now - last)

console.log(sum, newSum)
</code></pre><h4 id="&#x53C2;&#x8003;&#x8D44;&#x6599;">&#x53C2;&#x8003;&#x8D44;&#x6599;</h4>
<p><a href="https://book.douban.com/subject/26912767/" target="_blank">&#x6DF1;&#x5165;&#x7406;&#x89E3;&#x8BA1;&#x7B97;&#x673A;&#x7CFB;&#x7EDF;</a></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="locality.html" class="navigation navigation-prev " aria-label="Previous page: Locality">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="mobile recommendation.html" class="navigation navigation-next " aria-label="Next page: Mobile Recommendation">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Loop Unrolling","level":"1.31","depth":1,"next":{"title":"Mobile Recommendation","level":"1.32","depth":1,"path":"前端进阶/mobile recommendation.md","ref":"前端进阶/mobile recommendation.md","articles":[]},"previous":{"title":"Locality","level":"1.30","depth":1,"path":"前端进阶/locality.md","ref":"前端进阶/locality.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["summary","livereload"],"pluginsConfig":{"summary":{},"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"前端进阶/loop-unrolling.md","mtime":"2021-02-15T12:04:36.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-03-24T08:50:55.666Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

